import myfetch from "./myfetch"
import token from "./token"
import userType from "@/types/user"

function getMyInfo() {
  let userinfo: userType = {
    department: localStorage.getItem("haust-twxsh-dept_id"),
    name: localStorage.getItem("haust-twxsh-name"),
    status: localStorage.getItem("haust-twxsh-status"),
    qx: localStorage.getItem("haust-twxsh-qx"),
    id: localStorage.getItem("haust-twxsh-id")
  }
  return userinfo
}

function setUserInfo(param: userType) {

}
function getUserInfo(id: string) {
  let param = {
    id: token.getToken(id)
  }
  return myfetch.myget('/user/getUserInfo', param)
}
function getDepartmentPerson() {
  if (!getMyInfo().department) return
  let param = {
    department: getMyInfo().department || ""
  }
  return myfetch.myget('/user/getDepartmentPerson', param)
}
export default {
  getMyInfo, getUserInfo, getDepartmentPerson
}
